package com.example.warehouse.service.serviceImpl;

import com.example.warehouse.entity.OutStore;
import com.example.warehouse.mapper.OutstoreMapper;
import com.example.warehouse.page.Page1;
import com.example.warehouse.service.OutstoreService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OutstoreServiceImpl implements OutstoreService{
    @Autowired
    private OutstoreMapper outstoreMapper;

    @Override
    public void outstoreAdd(OutStore outStore) {
        outstoreMapper.outstoreAdd(outStore);
    }

    @Override
    public Page1 QueryPage(OutStore outStore, Page1 page1) {
        int count = outstoreMapper.getCount(outStore);
        List<OutStore> outStoreList = outstoreMapper.FindOutStorePage(outStore, page1);
        page1.setPageNum(count);
        page1.setResultList(outStoreList);
        return page1;
    }

    @Transactional
    @Override
    public void OutStoreConfirm(OutStore outStore) {
        outstoreMapper.OutStore(outStore.getOutsId());
        outstoreMapper.OutStoreConfirm(outStore.getStoreId(),outStore.getOutNum());
    }
}
